<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>fdk-aac: Decoder audio output</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">fdk-aac
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Decoder audio output </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="OutputFormatObtaining"></a>
Obtaining channel mapping information</h1>
<p>The decoded audio output format is indicated by a set of variables of the <a class="el" href="struct_c_stream_info.html" title="This structure gives information about the currently decoded audio data. All fields are read-only.">CStreamInfo</a> structure. While the struct members sampleRate, frameSize and numChannels might be self explanatory, pChannelType and pChannelIndices require some further explanation.</p>
<p>These two arrays indicate the configuration of channel data within the output buffer. Both arrays have <a class="el" href="struct_c_stream_info.html#ac1388034d207ca6075fc0883d39eea1a">CStreamInfo::numChannels</a> number of cells. Each cell of pChannelType indicates the channel type, which is described in the enum <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2">AUDIO_CHANNEL_TYPE</a> (defined in <a class="el" href="_f_d_k__audio_8h.html" title="Global audio struct and constant definitions.">FDK_audio.h</a>). The cells of pChannelIndices indicate the sub index among the channels starting with 0 among channels of the same audio channel type.</p>
<p>The indexing scheme is structured as defined in MPEG-2/4 Standards. Indices start from the front direction (a center channel if available, will always be index 0) and increment, starting with the left side, pairwise (e.g. L, R) and from front to back (Front L, Front R, Surround L, Surround R). For detailed explanation, please refer to ISO/IEC 13818-7:2005(E), chapter 8.5.3.2.</p>
<p>In case a Program Config is included in the audio configuration, the channel mapping described within it will be adopted.</p>
<p>The examples below explain these aspects in detail.</p>
<h1><a class="anchor" id="OutputFormatChange"></a>
Changing the audio output format</h1>
<p>For MPEG-4 audio the channel order can be changed at runtime through the parameter <a class="el" href="aacdecoder__lib_8h.html#aa34599717f4ed74b0c954cd57edc9f88ab49a2169c22ea876c67154d6caa04568">AAC_PCM_OUTPUT_CHANNEL_MAPPING</a>. See the description of those parameters and the decoder library function <a class="el" href="aacdecoder__lib_8h.html#afb42ea8892dd828264bd2f6147e0559f" title="Set one single decoder parameter.">aacDecoder_SetParam()</a> for more detail.</p>
<h1><a class="anchor" id="OutputFormatExample"></a>
Channel mapping examples</h1>
<p>The following examples illustrate the location of individual audio samples in the audio buffer that is passed to <a class="el" href="aacdecoder__lib_8h.html#a245a0e4176fb886d890a86627c55bb24" title="Decode one audio frame.">aacDecoder_DecodeFrame()</a> and the expected data in the <a class="el" href="struct_c_stream_info.html" title="This structure gives information about the currently decoded audio data. All fields are read-only.">CStreamInfo</a> structure which can be obtained by calling <a class="el" href="aacdecoder__lib_8h.html#a60aa42cb3ddc804b44ce61d877d0501e" title="Get CStreamInfo handle from decoder.">aacDecoder_GetStreamInfo()</a>.</p>
<h2><a class="anchor" id="ExamplesStereo"></a>
Stereo</h2>
<p>In case of <a class="el" href="aacdecoder__lib_8h.html#aa34599717f4ed74b0c954cd57edc9f88ab49a2169c22ea876c67154d6caa04568">AAC_PCM_OUTPUT_CHANNEL_MAPPING</a> set to 1, a AAC-LC bit stream which has channelConfiguration = 2 in its audio specific config would lead to the following values in <a class="el" href="struct_c_stream_info.html" title="This structure gives information about the currently decoded audio data. All fields are read-only.">CStreamInfo</a>:</p>
<p><a class="el" href="struct_c_stream_info.html#ac1388034d207ca6075fc0883d39eea1a">CStreamInfo::numChannels</a> = 2</p>
<p><a class="el" href="struct_c_stream_info.html#aae39329c51fe206a8aee33daba2fe1db">CStreamInfo::pChannelType</a> = { <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2abe7fbf568c90bf92779311ee05bdb8e3">ACT_FRONT</a>, <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2abe7fbf568c90bf92779311ee05bdb8e3">ACT_FRONT</a> }</p>
<p><a class="el" href="struct_c_stream_info.html#aa35e5be20f99be29ce12f9f41bf4d50e">CStreamInfo::pChannelIndices</a> = { 0, 1 }</p>
<p>The output buffer will be formatted as follows:</p>
<pre class="fragment">  &lt;left sample 0&gt;  &lt;left sample 1&gt;  &lt;left sample 2&gt;  ... &lt;left sample N&gt;
  &lt;right sample 0&gt; &lt;right sample 1&gt; &lt;right sample 2&gt; ... &lt;right sample N&gt;
</pre><p>Where N equals to <a class="el" href="struct_c_stream_info.html#a36fa897b242eebb936d99010a8c580be">CStreamInfo::frameSize</a> .</p>
<h2><a class="anchor" id="ExamplesSurround"></a>
Surround 5.1</h2>
<p>In case of <a class="el" href="aacdecoder__lib_8h.html#aa34599717f4ed74b0c954cd57edc9f88ab49a2169c22ea876c67154d6caa04568">AAC_PCM_OUTPUT_CHANNEL_MAPPING</a> set to 1, a AAC-LC bit stream which has channelConfiguration = 6 in its audio specific config, would lead to the following values in <a class="el" href="struct_c_stream_info.html" title="This structure gives information about the currently decoded audio data. All fields are read-only.">CStreamInfo</a>:</p>
<p><a class="el" href="struct_c_stream_info.html#ac1388034d207ca6075fc0883d39eea1a">CStreamInfo::numChannels</a> = 6</p>
<p><a class="el" href="struct_c_stream_info.html#aae39329c51fe206a8aee33daba2fe1db">CStreamInfo::pChannelType</a> = { <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2abe7fbf568c90bf92779311ee05bdb8e3">ACT_FRONT</a>, <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2abe7fbf568c90bf92779311ee05bdb8e3">ACT_FRONT</a>, <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2abe7fbf568c90bf92779311ee05bdb8e3">ACT_FRONT</a>, <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2aea74cc863b15e51e6cb0600a35d9d83f">ACT_LFE</a>, <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2a99e67ef350ed9ab71b15ad8ecf195e15">ACT_BACK</a>, <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2a99e67ef350ed9ab71b15ad8ecf195e15">ACT_BACK</a> }</p>
<p><a class="el" href="struct_c_stream_info.html#aa35e5be20f99be29ce12f9f41bf4d50e">CStreamInfo::pChannelIndices</a> = { 1, 2, 0, 0, 0, 1 }</p>
<p>Since <a class="el" href="aacdecoder__lib_8h.html#aa34599717f4ed74b0c954cd57edc9f88ab49a2169c22ea876c67154d6caa04568">AAC_PCM_OUTPUT_CHANNEL_MAPPING</a> is 1, WAV file channel ordering will be used. For a 5.1 channel scheme, thus the channels would be: front left, front right, center, LFE, surround left, surround right. Thus the third channel is the center channel, receiving the index 0. The other front channels are front left, front right being placed as first and second channels with indices 1 and 2 correspondingly. There is only one LFE, placed as the fourth channel and index 0. Finally both surround channels get the type definition ACT_BACK, and the indices 0 and 1.</p>
<p>The output buffer will be formatted as follows:</p>
<pre class="fragment">&lt;front left sample 0&gt; &lt;front right sample 0&gt;
&lt;center sample 0&gt; &lt;LFE sample 0&gt;
&lt;surround left sample 0&gt; &lt;surround right sample 0&gt;

&lt;front left sample 1&gt; &lt;front right sample 1&gt;
&lt;center sample 1&gt; &lt;LFE sample 1&gt;
&lt;surround left sample 1&gt; &lt;surround right sample 1&gt;

...

&lt;front left sample N&gt; &lt;front right sample N&gt;
&lt;center sample N&gt; &lt;LFE sample N&gt;
&lt;surround left sample N&gt; &lt;surround right sample N&gt;
</pre><p>Where N equals to <a class="el" href="struct_c_stream_info.html#a36fa897b242eebb936d99010a8c580be">CStreamInfo::frameSize</a> .</p>
<h2><a class="anchor" id="ExamplesArib"></a>
ARIB coding mode 2/1</h2>
<p>In case of <a class="el" href="aacdecoder__lib_8h.html#aa34599717f4ed74b0c954cd57edc9f88ab49a2169c22ea876c67154d6caa04568">AAC_PCM_OUTPUT_CHANNEL_MAPPING</a> set to 1, in case of a ARIB bit stream using coding mode 2/1 as described in ARIB STD-B32 Part 2 Version 2.1-E1, page 61, would lead to the following values in <a class="el" href="struct_c_stream_info.html" title="This structure gives information about the currently decoded audio data. All fields are read-only.">CStreamInfo</a>:</p>
<p><a class="el" href="struct_c_stream_info.html#ac1388034d207ca6075fc0883d39eea1a">CStreamInfo::numChannels</a> = 3</p>
<p><a class="el" href="struct_c_stream_info.html#aae39329c51fe206a8aee33daba2fe1db">CStreamInfo::pChannelType</a> = { <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2abe7fbf568c90bf92779311ee05bdb8e3">ACT_FRONT</a>, <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2abe7fbf568c90bf92779311ee05bdb8e3">ACT_FRONT</a>, <a class="el" href="_f_d_k__audio_8h.html#ae2e99eec9b2aff4efbe944c0613a22e2a99e67ef350ed9ab71b15ad8ecf195e15">ACT_BACK</a> }</p>
<p><a class="el" href="struct_c_stream_info.html#aa35e5be20f99be29ce12f9f41bf4d50e">CStreamInfo::pChannelIndices</a> = { 0, 1, 0 }</p>
<p>The audio channels will be placed as follows in the audio output buffer:</p>
<pre class="fragment">&lt;front left sample 0&gt; &lt;front right sample 0&gt;  &lt;mid surround sample 0&gt;

&lt;front left sample 1&gt; &lt;front right sample 1&gt; &lt;mid surround sample 1&gt;

...

&lt;front left sample N&gt; &lt;front right sample N&gt; &lt;mid surround sample N&gt;

Where N equals to CStreamInfo::frameSize .</pre> </div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
